package org.dromara.system.business.applicationManage.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.checkerframework.checker.units.qual.A;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.utils.BeanUtils;
import org.dromara.system.business.applicationManage.domain.ApplicationManage;
import org.dromara.system.business.applicationManage.domain.dto.AppManageParamDTO;
import org.dromara.system.business.applicationManage.domain.vo.AppManageVO;
import org.dromara.system.business.applicationManage.service.ApplicationManageService;
import org.dromara.system.business.applicationManage.mapper.ApplicationManageMapper;
import org.dromara.system.business.label.domain.LabelManage;
import org.dromara.system.common.UploadFiles;
import org.dromara.system.enums.BussinessTableEnum;
import org.dromara.system.service.BusinessFileRelService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

/**
* @author chs
* @description 针对表【application_manage】的数据库操作Service实现
* @createDate 2025-02-08 15:19:04
*/
@Service
public class ApplicationManageServiceImpl extends ServiceImpl<ApplicationManageMapper, ApplicationManage>
    implements ApplicationManageService{

    @Resource
    private BusinessFileRelService businessFileRelService;
    @Override
    @Transactional
    public Boolean applicationAdd(AppManageParamDTO appManageParamDTO) {
        //空数据判断
        if (ObjectUtil.isEmpty(appManageParamDTO)){
            throw new RuntimeException("新增应用传入参数为空");
        }
        //数据校验

        //数据转换
        ApplicationManage applicationManage = BeanUtils.copy(appManageParamDTO, ApplicationManage.class);
        applicationManage.setReleaseTime(LocalDateTime.now());
        //主数据保存
        boolean saveMain = this.save(applicationManage);
        //图片、标签数据保存
        List<UploadFiles> files = appManageParamDTO.getFiles();
        Boolean mesSave = businessFileRelService.fileMesSave(applicationManage.getId(), BussinessTableEnum.ApplicationManage.getValue(), files);
        List<LabelManage> labelManages = appManageParamDTO.getLabelManages();
        return null;
    }

    @Override
    public Page appQuery(AppManageParamDTO appManageParamDTO) {
        return null;
    }

    @Override
    public Boolean appUpdate(AppManageParamDTO appManageParamDTO) {
        return null;
    }

    @Override
    public AppManageVO appDetail(Long id) {
        return null;
    }

    @Override
    public Boolean appDelete(Long id) {
        return this.removeById(id);
    }
}




